home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compendium Deluxe 2
/
LSD and 17bit Compendium Deluxe - Volume II.iso
/
a
/
prog
/
misc
/
date.lha
/
Date
/
Oberon
/
txt
/
test.mod
< prev
next >
Wrap
Text File
|
1994-08-11
|
14KB
|
388 lines
MODULE test;
IMPORT Date, io, RealInOut;
PROCEDURE readintyear() : INTEGER;
VAR
year : INTEGER;
BEGIN
io.WriteString("(integer)year: ");
io.ReadIntegerOk(year);
RETURN(year);
END readintyear;
PROCEDURE readshortcardmonth() : SHORTINT;
VAR
month : INTEGER;
BEGIN
io.WriteString("(shortcard)month: "); io.ReadIntegerOk(month);
RETURN(SHORT(month));
END readshortcardmonth;
PROCEDURE readshortcardday() : SHORTINT;
VAR
day : INTEGER;
BEGIN
io.WriteString("(shortcard)day: "); io.ReadIntegerOk(day);
RETURN(SHORT(day));
END readshortcardday;
PROCEDURE readweekday() : Date.Weekdays;
VAR
wday : INTEGER;
BEGIN
REPEAT
io.WriteString("weekday: 1=Monday; ...7=Sunday: ");
io.ReadIntegerOk(wday);
UNTIL (wday < 8) AND (wday > -1);
RETURN(SHORT(wday));
END readweekday;
PROCEDURE readintdays() : INTEGER;
VAR
days : INTEGER;
BEGIN
io.WriteString("(integer)days: ");
io.ReadIntegerOk(days);
RETURN(days);
END readintdays;
PROCEDURE readcardyear() : INTEGER;
VAR
year : INTEGER;
BEGIN
io.WriteString("(cardinal)year: "); io.ReadIntegerOk(year);
RETURN(year);
END readcardyear;
PROCEDURE readlongcarddays() : LONGINT;
VAR
day : LONGINT;
BEGIN
io.WriteString("(longcard)days: "); io.ReadIntOk(day);
RETURN(day);
END readlongcarddays;
PROCEDURE readshortcardhour() : SHORTINT;
VAR
hour : INTEGER;
BEGIN
io.WriteString("(shortcard)hour: "); io.ReadIntegerOk(hour);
RETURN(SHORT(hour));
END readshortcardhour;
PROCEDURE readshortcardmin() : SHORTINT;
VAR
min : INTEGER;
BEGIN
io.WriteString("(shortcard)min: "); io.ReadIntegerOk(min);
RETURN(SHORT(min));
END readshortcardmin;
PROCEDURE readshortcardsec() : SHORTINT;
VAR
sec : INTEGER;
BEGIN
io.WriteString("(shortcard)sec: "); io.ReadIntegerOk(sec);
RETURN(SHORT(sec));
END readshortcardsec;
PROCEDURE readrealtime() : REAL;
VAR
jd : REAL;
err : BOOLEAN;
BEGIN
io.WriteString("(real)time: ");
err := RealInOut.ReadReal(jd);
RETURN(jd);
END readrealtime;
PROCEDURE readshortintdegree() : SHORTINT;
VAR
degree : INTEGER;
BEGIN
io.WriteString("(shortint)degree: ");
io.ReadIntegerOk(degree);
RETURN(SHORT(degree));
END readshortintdegree;
PROCEDURE readlongcardsecs() : LONGINT;
VAR
secs : LONGINT;
BEGIN
io.WriteString("(longcard)secs: "); io.ReadIntOk(secs);
RETURN(secs);
END readlongcardsecs;
PROCEDURE readrealmeridian() : REAL;
VAR
jd : REAL;
err : BOOLEAN;
BEGIN
io.WriteString("(real)meridian: ");
err := RealInOut.ReadReal(jd);
RETURN(jd);
END readrealmeridian;
PROCEDURE readrealpos() : REAL;
VAR
jd : REAL;
err : BOOLEAN;
BEGIN
io.WriteString("(real)ps: ");
err := RealInOut.ReadReal(jd);
RETURN(jd);
END readrealpos;
VAR
input,repeat : INTEGER;
wd : Date.Weekdays;
d,m,h,s : SHORTINT;
y : INTEGER;
err : BOOLEAN;
BEGIN
REPEAT
io.WriteString("----------------------------------------------------------------\n");
io.WriteString("01 : JulianLeapYear | 02 : GregorianLeapYear\n");
io.WriteString("03 : HeisLeapYear | 04 : JulianMonthDays\n");
io.WriteString("05 : GregorianMonthDays | 06 : HeisMonthDays\n");
io.WriteString("07 : JulianYearDays | 08 : GregorianYearDays\n");
io.WriteString("09 : HeisYearDays | 10 : JulianDayDiff\n");
io.WriteString("11 : GregorianDayDiff | 12 : HeisDayDiff\n");
io.WriteString("13 : JulianDaySmaller | 14 : GregorianDaySmaller\n");
io.WriteString("15 : HeisDaySmaller | 16 : JulianWeekday\n");
io.WriteString("17 : GregorianWeekday | 18 : HeisWeekday\n");
io.WriteString("19 : JulianDaysBeforeWeekday | 20 : GregorianDaysBeforeWeekday\n");
io.WriteString("21 : HeisDaysBeforeWeekday | 22 : JulianDaysAfterWeekday\n");
io.WriteString("23 : GregorianDaysAfterWeekday | 24 : HeisDaysAfterWeekday\n");
io.WriteString("25 : JulianDiffDate | 26 : GregorianDiffDate\n");
io.WriteString("27 : HeisDiffDate | 28 : JYearToScaliger\n");
io.WriteString("29 : GYearToScaliger | 30 : HYearToScaliger\n");
io.WriteString("31 : ScaligerYearToJ | 32 : ScaligerYearToG\n");
io.WriteString("33 : ScaligerYearToH | 34 : JSYearToJD\n");
io.WriteString("35 : GSYearToJD | 36 : HSYearToJD\n");
io.WriteString("37 : JDtoMJD | 38 : MJDtoJD\n");
io.WriteString("39 : JulianToJD | 40 : GregorianToJD\n");
io.WriteString("41 : HeisToJD | 42 : TimeToJD\n");
io.WriteString("43 : JDToTime | 44 : GregorianMoonAge\n");
io.WriteString("45 : GregorianEaster | 46 : TimeZoneFactor\n");
io.WriteString("47 : LMT | 48 : TimeToSec\n");
io.WriteString("49 : SecToTime | 50 : JulianWeek\n");
io.WriteString("51 : GregorianWeek | 52 : HeisWeek\n");
io.WriteString("00 : Quit\n");
io.WriteString("It's your turn: "); io.ReadIntegerOk(input);
io.WriteString("----------------------------------------------------------------\n");
REPEAT
CASE input OF
0 : ;|
1 : IF Date.JulianLeapYear(readintyear()) THEN
io.WriteString("TRUE\n");;
ELSE
io.WriteString("FALSE\n");
END;|
2 : IF Date.GregorianLeapYear(readintyear()) THEN
io.WriteString("TRUE\n");;
ELSE
io.WriteString("FALSE\n");
END;|
3 : IF Date.HeisLeapYear(readintyear()) THEN
io.WriteString("TRUE\n");;
ELSE
io.WriteString("FALSE\n");
END;|
4 : io.WriteInt(Date.JulianMonthDays(readshortcardmonth(),readintyear()),3);
io.WriteLn;|
5 : io.WriteInt(Date.GregorianMonthDays(readshortcardmonth(),readintyear()),3);
io.WriteLn;|
6 : io.WriteInt(Date.HeisMonthDays(readshortcardmonth(),readintyear()),3);
io.WriteLn;|
7 : io.WriteInt(Date.JulianYearDays(readintyear()),4);
io.WriteLn;|
8 : io.WriteInt(Date.GregorianYearDays(readintyear()),4);
io.WriteLn;|
9 : io.WriteInt(Date.HeisYearDays(readintyear()),4);
io.WriteLn;|
10 : io.WriteInt(Date.JulianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
io.WriteLn;|
11 : io.WriteInt(Date.GregorianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
io.WriteLn;|
12 : io.WriteInt(Date.HeisDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
io.WriteLn;|
13 : IF Date.JulianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
io.WriteString("TRUE\n");;
ELSE
io.WriteString("FALSE\n");
END;|
14 : IF Date.GregorianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
io.WriteString("TRUE\n");;
ELSE
io.WriteString("FALSE\n");
END;|
15 : IF Date.HeisDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
io.WriteString("TRUE\n");;
ELSE
io.WriteString("FALSE\n");
END;|
16 : wd := Date.JulianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
CASE wd OF
Date.dayerr : io.WriteString("dayerr!\n");|
Date.Monday : io.WriteString("Monday\n");|
Date.Tuesday : io.WriteString("Tuesday\n");|
Date.Wednesday : io.WriteString("Wednesday\n");|
Date.Thursday : io.WriteString("Thursday\n");|
Date.Friday : io.WriteString("Friday\n");|
Date.Saturday : io.WriteString("Saturday\n");|
Date.Sunday : io.WriteString("Sunday\n");
ELSE
io.WriteString("Illegal Code!\n");
END;|
17 : wd := Date.GregorianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
CASE wd OF
Date.dayerr : io.WriteString("dayerr!\n");|
Date.Monday : io.WriteString("Monday\n");|
Date.Tuesday : io.WriteString("Tuesday\n");|
Date.Wednesday : io.WriteString("Wednesday\n");|
Date.Thursday : io.WriteString("Thursday\n");|
Date.Friday : io.WriteString("Friday\n");|
Date.Saturday : io.WriteString("Saturday\n");|
Date.Sunday : io.WriteString("Sunday\n");
ELSE
io.WriteString("Illegal Code!\n");
END;|
18 : wd := Date.HeisWeekday(readshortcardday(),readshortcardmonth(),readintyear());
CASE wd OF
Date.dayerr : io.WriteString("dayerr!\n");|
Date.Monday : io.WriteString("Monday\n");|
Date.Tuesday : io.WriteString("Tuesday\n");|
Date.Wednesday : io.WriteString("Wednesday\n");|
Date.Thursday : io.WriteString("Thursday\n");|
Date.Friday : io.WriteString("Friday\n");|
Date.Saturday : io.WriteString("Saturday\n");|
Date.Sunday : io.WriteString("Sunday\n");
ELSE
io.WriteString("Illegal Code!\n");
END;|
19 : io.WriteInt(Date.JulianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
io.WriteLn;|
20 : io.WriteInt(Date.GregorianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
io.WriteLn;|
21 : io.WriteInt(Date.HeisDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
io.WriteLn;|
22 : io.WriteInt(Date.JulianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
io.WriteLn;|
23 : io.WriteInt(Date.GregorianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
io.WriteLn;|
24 : io.WriteInt(Date.HeisDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
io.WriteLn;|
25 : Date.JulianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteInt(y,4); io.WriteLn;|
26 : Date.GregorianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteInt(y,4); io.WriteLn;|
27 : Date.HeisDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteInt(y,4); io.WriteLn;|
28 : io.WriteInt(Date.JYearToScaliger(readintyear()),10);
io.WriteLn;|
29 : io.WriteInt(Date.GYearToScaliger(readintyear()),10);
io.WriteLn;|
30 : io.WriteInt(Date.HYearToScaliger(readintyear()),10);
io.WriteLn;|
31 : io.WriteInt(Date.ScaligerYearToJ(readcardyear()),5);
io.WriteLn;|
32 : io.WriteInt(Date.ScaligerYearToG(readcardyear()),5);
io.WriteLn;|
33 : io.WriteInt(Date.ScaligerYearToH(readcardyear()),5);
io.WriteLn;|
34 : io.WriteInt(Date.JSYearToJD(readcardyear()),10);
io.WriteLn;|
35 : io.WriteInt(Date.GSYearToJD(readcardyear()),10);
io.WriteLn;|
36 : io.WriteInt(Date.HSYearToJD(readcardyear()),10);
io.WriteLn;|
37 : io.WriteInt(Date.JDtoMJD(readlongcarddays()),10);
io.WriteLn;|
38 : io.WriteInt(Date.MJDtoJD(readlongcarddays()),10);
io.WriteLn;|
39 : io.WriteInt(Date.JulianToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
io.WriteLn;|
40 : io.WriteInt(Date.GregorianToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
io.WriteLn;|
41 : io.WriteInt(Date.HeisToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
io.WriteLn;|
42 : err := RealInOut.WriteReal(Date.TimeToJD(readshortcardhour(),readshortcardmin(),readshortcardsec()),20,10,FALSE);
io.WriteLn;|
43 : Date.JDToTime(readrealtime(),h,m,s);
io.WriteInt(h,2); io.WriteString(":"); io.WriteInt(m,2); io.WriteString(":"); io.WriteInt(s,2); io.WriteLn;|
44 : io.WriteInt(Date.GregorianMoonAge(readshortcardday(),readshortcardmonth(),readintyear()),2);
io.WriteLn;|
45 : Date.GregorianEaster(readintyear(),d,m);
io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteLn;|
46 : io.WriteInt(Date.TimeZoneFactor(readshortintdegree()),2); io.WriteLn;|
47 : io.WriteInt(Date.LMT(readlongcardsecs(),readrealmeridian(),readrealpos()),10); io.WriteLn;|
48 : io.WriteInt(Date.TimeToSec(readshortcardhour(),readshortcardmin(),readshortcardsec()),10); io.WriteLn;|
49 : Date.SecToTime(readlongcardsecs(),h,m,s);
io.WriteInt(h,2); io.WriteString(":"); io.WriteInt(m,2); io.WriteString(":"); io.WriteInt(s,2); io.WriteLn;|
50 : io.WriteInt(Date.JulianWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); io.WriteLn;|
51 : io.WriteInt(Date.GregorianWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); io.WriteLn;|
52 : io.WriteInt(Date.HeisWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); io.WriteLn;
ELSE
io.WriteString("Wong number! Try again!\n");
END;
IF input > 0 THEN
io.WriteString("0 : Menue; >0 : test again - ");
io.ReadIntegerOk(repeat);
ELSE
repeat := 0;
END;
UNTIL repeat = 0;
UNTIL input = 0;
END test.